# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/aosp_kanuti_tulip_defconfig

pkgname=linux-sony-tulip
pkgver=3.10
pkgrel=4
pkgdesc="Sony Xperia M4 Aqua kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="sony-tulip"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev openssl openssl-dev gcc6"

# Compiler: GCC 6 (doesn't boot when compiled with newer versions)
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	HOSTCC="gcc6-gcc"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi


# Source
_repository="kernel_kanuti"
_commit="d8e51bc7dd6bde228f1d9a7ddcf664845c4f07fb"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/bartcubbins/$_repository/archive/$_commit.tar.gz
	$_config
	gcc10-extern_YYLOC_global_declaration.patch
	0001-posix_acl-fix-bad-kernel-backport.patch
"
builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor"
}

sha512sums="7372b4fdfca2fef3c8ae48c9353a6d7ea658fc8412e2b288ee1097d902f5d9b81a0b76f3fc0e1bc74a015ec34e84c4942608f0e522d628b3deb288f4b177428c  linux-sony-tulip-d8e51bc7dd6bde228f1d9a7ddcf664845c4f07fb.tar.gz
72183314f38428c430ae455779237d1f4702271d0b072e2464e7bd2cc9a768c5c61037251c9b4b3ff411c75151af3287de5b443187f13a4f6b7655ba7947f44e  config-sony-tulip.aarch64
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch
62c27cb75bbfd65ead3a5345ab81e356f04da803b45ce14239d95694adc675c4dced89de7582ae2f0e229b176f545cc76a6706c9774d48eabcbb010f83623268  0001-posix_acl-fix-bad-kernel-backport.patch"
